package com.mco.controller;

import com.mco.service.GeoService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.GeoResults;
import org.springframework.data.geo.Point;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ：liao.wei
 * @date ：2023/9/20 20:59
 * @package : com.mco.controller
 */
@RequiredArgsConstructor
@RestController
@RequestMapping
public class GeoController {
	@Resource
	private GeoService geoservice;
	
	@RequestMapping(value = "geoadd", method = RequestMethod.GET)
	public String geoAdd() {
		return geoservice.geoAdd();
	}
	
	@RequestMapping(value = "/geopos", method = RequestMethod.GET)
	public Point position(String member) {
		return geoservice.position(member);
	}
	
	@RequestMapping(value = "/geohash", method = RequestMethod.GET)
	public String hash(String member) {
		return geoservice.hash(member);
	}
	
	@RequestMapping(value = "/geodist", method = RequestMethod.GET)
	public Distance distance(String member1, String member2) {
		return geoservice.distance(member1, member2);
	}
	
	@RequestMapping(value = "/georadius", method = RequestMethod.GET)
	public GeoResults radiusByxy() {
		return geoservice.radiusByxy();
	}
	
	@RequestMapping(value = "/georadiusByMember", method = RequestMethod.GET)
	public GeoResults radiusByMember() {
		return geoservice.radiusByMember();
	}
}
